package com.lzx.iteam.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import com.lzx.iteam.util.PreferenceUtil;

/**
 * Created by hfx on 14-12-11.
 * @author liukun
 */
public class VerticalKeyPadScrollLayout extends RelativeLayout {
    Context mContext;
    public VerticalKeyPadScrollLayout(Context context){
        super(context);
    }

    public VerticalKeyPadScrollLayout(Context context, AttributeSet attrs) {
        super(context, attrs);
        mContext = context;
    }

    @Override
    protected void onLayout(boolean changed, int l, int t, int r, int b) {
        super.onLayout(changed, l, t, r, b);
        if(isInEditMode()){
            return;
        }
        PreferenceUtil preferenceUtil = PreferenceUtil.getInstance(mContext);
        ViewGroup keyPad = (ViewGroup) getChildAt(0);
        int defaultTop = (getHeight()-keyPad.getHeight())/2;
        int top = preferenceUtil.getInt(PreferenceUtil.VERTICAL_KEYBOARD_LAST_TOP,defaultTop);
        int right = getWidth();
        int bottom = top + keyPad.getHeight();
        keyPad.layout(0,top,right,bottom);
        Log.i("VerticalPad","top:"+top+"bottom"+bottom);
    }
}
